package com.micro.school.system.controller.discount;

import java.util.List;

import com.micro.school.common.core.utils.poi.ExcelUtil;
import com.micro.school.common.core.web.controller.BaseController;
import com.micro.school.common.core.web.domain.AjaxResult;
import com.micro.school.common.core.web.page.TableDataInfo;
import com.micro.school.common.log.annotation.Log;
import com.micro.school.common.log.enums.BusinessType;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.micro.school.system.domain.vo.DiscountActivityVo;
import com.ruoyi.system.service.IDiscountActivityService;

/**
 * 【学校优惠活动】Controller
 * 
 * @author rakic
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/activity")
public class DiscountActivityController extends BaseController
{
    @Autowired
    private IDiscountActivityService discountActivityService;

    /**
     * 查询【学校优惠活动】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DiscountActivityVo discountActivityVo)
    {
        startPage();
        List<DiscountActivityVo> list = discountActivityService.selectDiscountActivityList(discountActivityVo);
        return getDataTable(list);
    }

    /**
     * 导出【学校优惠活动】列表
     */
    @Log(title = "【学校优惠活动】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DiscountActivityVo discountActivityVo)
    {
        List<DiscountActivityVo> list = discountActivityService.selectDiscountActivityList(discountActivityVo);
        ExcelUtil<DiscountActivityVo> util = new ExcelUtil<DiscountActivityVo>(DiscountActivityVo.class);
        util.exportExcel(response, list, "【学校优惠活动】数据");
    }

    /**
     * 获取【学校优惠活动】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(discountActivityService.selectDiscountActivityById(id));
    }

    /**
     * 新增【学校优惠活动】
     */
    @Log(title = "【学校优惠活动】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DiscountActivityVo discountActivityVo)
    {
        return toAjax(discountActivityService.insertDiscountActivity(discountActivityVo));
    }

    /**
     * 修改【学校优惠活动】
     */
    @Log(title = "【学校优惠活动】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DiscountActivityVo discountActivityVo)
    {
        return toAjax(discountActivityService.updateDiscountActivity(discountActivityVo));
    }

    /**
     * 删除【学校优惠活动】
     */
    @Log(title = "【学校优惠活动】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(discountActivityService.deleteDiscountActivityByIds(ids));
    }


}
